/**
 * 涉税查询
 * @author 黄广星 基础UI搭建
 * @author 程文智 UI微调(ActionBar颜色及子模块UI)
 */
package com.taxsystem.huangguangxing.taxrelatedcheck;

import com.main.taxsystem.R;
import java.util.ArrayList;

import java.util.HashMap;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.SimpleAdapter;

public class TaxrelatedcheckMainActivity extends Activity {

	GridView gridView;
	// 当长度过长换行时出现显示问题
	private final static String TITLES[] = { 
		"登记信息查询", 
		"纳税核定查询", 
		"发票资格认定", 
		"审批办结查询", 
		"社保缴费查询",
		"缴税情况查询 " };
	private final static int[] DRAWABLE_ID = {
		R.drawable.djxxcx,
		R.drawable.nshdcx,
		R.drawable.temp_logo,//TODO:没有切片
		R.drawable.temp_logo,
		R.drawable.sbjfcx,
		R.drawable.temp_logo
	};

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.grid_view);

		gridView = (GridView) findViewById(R.id.gridView);

		ArrayList<HashMap<String, Object>> lstImageItem = new ArrayList<HashMap<String, Object>>();
		for (int i = 0; i < TITLES.length; i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			map.put("icon", DRAWABLE_ID[i]);// 添加图像资源的ID
			map.put("title", TITLES[i]);// 添加标题
			lstImageItem.add(map);
		}
		SimpleAdapter saImageItems = new SimpleAdapter(this, lstImageItem,
				R.layout.grid_item, new String[] {
						"icon", "title" }, new int[] { R.id.image_item,
						R.id.text_item });
		gridView.setAdapter(saImageItems);
		gridView.setOnItemClickListener(new ItemClickListener());
	}

	// 当AdapterView被单击(触摸屏或者键盘)，则返回的Item单击事件
	class ItemClickListener implements OnItemClickListener {
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
				long arg3) {
			Intent intent = new Intent();
			/* 指定intent要启动的类 */
			intent.setClass(TaxrelatedcheckMainActivity.this,
					TaxrelatedcheckShowTitleActivity.class);
			/* 启动一个新的Activity */
			startActivity(intent);
		}
	}

}
